package chapter06

/**
 * 匿名子类
 *
 * 跟实现具体的子类、然后创建对应的实例、再去调用这个方法得到结果、是一摸一样的
 */
object Test10_AnnoymousClass {
  def main(args: Array[String]): Unit = {

    val person: Person10 = new Person10 {

//      重写
      override var name: String = "张三"

      override def eat(): Unit = println("person eat")

    }
    println(person.name)
    person.eat()
  }
}


//定义抽象类
abstract class Person10 {
  var name: String

  def eat(): Unit
}
